<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creates a new DOMElement object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.domelement.html">DOMElement</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="domelement.getattribute.html">DOMElement::getAttribute</a></div>
 <div class="up"><a href="class.domelement.html">DOMElement</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="domelement.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DOMElement::__construct</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">DOMElement::__construct</span> &mdash; <span class="dc-title">
   Creates a new DOMElement object
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-domelement.construct-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>DOMElement::__construct</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$value</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$namespaceURI</code></span>
  ]] )</div>
 
  <p class="para rdfs-comment">
   Creates a new <a href="class.domelement.html" class="classname">DOMElement</a> object. This object is read only. 
   It may be appended to a document, but additional nodes may not be appended to this node until 
   the node is associated with a document. To create a writeable node, use 
   <a href="domdocument.createelement.html" class="xref">DOMDocument::createElement</a> or 
   <a href="domdocument.createelementns.html" class="xref">DOMDocument::createElementNS</a>.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-domelement.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">name</code></em></dt>

     <dd>

      <p class="para">
       The tag name of the element. When also passing in namespaceURI, the element name 
       may take a prefix to be associated with the URI.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">value</code></em></dt>

     <dd>

      <p class="para">
       The value of the element.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">namespaceURI</code></em></dt>

     <dd>

      <p class="para">
       A namespace URI to create the element within a specific namespace.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-domelement.construct-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5302">
    <p><strong>Example #1 Creating a new DOMElement</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$dom&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">(</span><span style="color: #DD0000">'1.0'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'iso-8859-1'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$element&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">appendChild</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">DOMElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'root'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$element_ns&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DOMElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'pr:node1'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'thisvalue'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'http://xyz'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$element</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">appendChild</span><span style="color: #007700">(</span><span style="color: #0000BB">$element_ns</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">saveXML</span><span style="color: #007700">();&nbsp;</span><span style="color: #FF8000">/*&nbsp;&lt;?xml&nbsp;version="1.0"&nbsp;encoding="utf-8"?&gt;<br />&lt;root&gt;&lt;pr:node1&nbsp;xmlns:pr="http://xyz"&gt;thisvalue&lt;/pr:node1&gt;&lt;/root&gt;&nbsp;*/<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-domelement.construct-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="domdocument.createelement.html" class="methodname" rel="rdfs-seeAlso">DOMDocument::createElement()</a> - Create new element node</span></li>
    <li class="member"><span class="methodname"><a href="domdocument.createelementns.html" class="methodname" rel="rdfs-seeAlso">DOMDocument::createElementNS()</a> - Create new element node with an associated namespace</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.domelement.html">DOMElement</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="domelement.getattribute.html">DOMElement::getAttribute</a></div>
 <div class="up"><a href="class.domelement.html">DOMElement</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
